package cn.explink.dop.distributor.condition;

import java.util.List;

import cn.explink.distributor.framework.Condition;
import cn.explink.distributor.framework.enums.ConditionTypeEnum;

public class RefuseDeliveryMan extends MatchableCondition {

	private static final long serialVersionUID = 3750690103474077457L;
	// 店面可能有多个配送人员
	private List<String> refusedeleveryManIdList;

	public RefuseDeliveryMan() {
		this.setType(ConditionTypeEnum.Matchable.getValue());
	}
	/**
	 * 用于订单中被拒配送员列表和配送员id进行对比
	 */
	@Override
	public boolean isMatched(Condition condition) {
		for (String refusedeliveryManId_storefront : this.refusedeleveryManIdList) {
			for (String refusedeliveryManId : ((RefuseDeliveryMan) condition)
					.getRefusedeleveryManIdList()) {
				if (refusedeliveryManId_storefront.equals(refusedeliveryManId)) {
					return false;
				}
			}
		}
		return true;
	}
	/**
	 * 
	* @Title: isEqual 
	* @Description: 用于对比一个订单中的被拒配送员列表和可用配送员列表
	* @author 小强
	* @param @param condition
	* @param @return    设定文件 
	* @return boolean    返回类型 
	* @throws
	 */
	public boolean isEqual(Condition condition){
		int i = 0;
		int j = ((HavingDeliveryMan)condition).getDeleveryManIdList().size();
		for (String order_havingDeliveryMan : ((HavingDeliveryMan) condition).getDeleveryManIdList()) {
			for (String refusedeliveryManId_storefront : this.refusedeleveryManIdList) {			
				if (refusedeliveryManId_storefront.equals(order_havingDeliveryMan)) {
					i++;
				}
			}
		}
		if(i == j){
			return true;
		}
		return false;
	}
	
	public List<String> getRefusedeleveryManIdList() {
		return refusedeleveryManIdList;
	}

	public void setRefusedeleveryManIdList(List<String> refusedeleveryManIdList) {
		this.refusedeleveryManIdList = refusedeleveryManIdList;
	}
	
}
